package demo;

import java.lang.management.ManagementFactory;

import javax.management.MBeanInfo;
import javax.management.MBeanServer;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;

public class Server {

	public static void main(String[] args) throws Exception {
		method1();
	}

	public static void method1() throws Exception {


		JMXServiceURL address = new JMXServiceURL(
				"service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi");
		JMXConnector connector = JMXConnectorFactory.connect(address);
		
		MBeanServerConnection mbsc = connector.getMBeanServerConnection();
		
		ObjectName objectName = new ObjectName("demo:name=MonitorBlog");		
		
		System.out.println(mbsc.getAttribute(objectName, "LoginCounts"));
		System.out.println(mbsc.getAttribute(objectName, "PublishCounts"));
		
		
		
		

	}
}
